<?php
namespace app\classes\helper;
class Date
{
    /*
     * 计算两个日期之间的天数
     */
    public static function days($start_date,$end_date)
    {
        $days = floor(( strtotime($end_date) - strtotime($start_date) ) / 86400 );

        return $days;
    }

    /*
     * 计算当前月第一天和最后一天日期
     */
    public static function date_range($date)
    {

        $start_date = date('Y-m-01', strtotime( $date ) );
        $end_date   = date('Y-m-d', strtotime("$start_date +1 month -1 day"));

        return [ 'start_date'=>$start_date, 'end_date'=>$end_date ];
    }
}